﻿package com.example.demo.dao
import com.example.demo.dao.*
import me.liuwj.ktorm.entity.Entity
import me.liuwj.ktorm.schema.Table
import me.liuwj.ktorm.database.Database
import me.liuwj.ktorm.entity.sequenceOf
import me.liuwj.ktorm.dsl.*
import me.liuwj.ktorm.entity.EntitySequence
import me.liuwj.ktorm.schema.BaseTable
import me.liuwj.ktorm.schema.ColumnDeclaring

/**
 * codeGen version:1.9
 * codeGen github:https://github.com/yuzd/AntData.ORM
**/
object Tables {
    val tApk = TApkDao
    val Database.tApks get() = this.sequenceOf(TApkDao)
    val tBoardMessage = TBoardMessageDao
    val Database.tBoardMessages get() = this.sequenceOf(TBoardMessageDao)
    val tDeptVideo = TDeptVideoDao
    val Database.tDeptVideos get() = this.sequenceOf(TDeptVideoDao)
    /**
     *  设备
     **/
    val tDevice = TDeviceDao
    /**
     *  设备
     **/
    val Database.tDevices get() = this.sequenceOf(TDeviceDao)
    val tFood = TFoodDao
    val Database.tFoods get() = this.sequenceOf(TFoodDao)
    val tFoodType = TFoodTypeDao
    val Database.tFoodTypes get() = this.sequenceOf(TFoodTypeDao)
    /**
     *  菜单表
     **/
    val tMenu = TMenuDao
    /**
     *  菜单表
     **/
    val Database.tMenus get() = this.sequenceOf(TMenuDao)
    val tPressure = TPressureDao
    val Database.tPressures get() = this.sequenceOf(TPressureDao)
    val tProduct = TProductDao
    val Database.tProducts get() = this.sequenceOf(TProductDao)
    val tProductType = TProductTypeDao
    val Database.tProductTypes get() = this.sequenceOf(TProductTypeDao)
    val tQuestionnaire = TQuestionnaireDao
    val Database.tQuestionnaires get() = this.sequenceOf(TQuestionnaireDao)
    val tQuestionnaireAnswer = TQuestionnaireAnswerDao
    val Database.tQuestionnaireAnswers get() = this.sequenceOf(TQuestionnaireAnswerDao)
    val tQuestionnairePost = TQuestionnairePostDao
    val Database.tQuestionnairePosts get() = this.sequenceOf(TQuestionnairePostDao)
    val tTemperature = TTemperatureDao
    val Database.tTemperatures get() = this.sequenceOf(TTemperatureDao)
    /**
     *  用户数据表
     **/
    val tUser = TUserDao
    /**
     *  用户数据表
     **/


    val Database.tUsers get() = this.sequenceOf(TUserDao)


    /**
     *  病床视图
     **/
    val tJzrBed = TJzrBedDao
    /**
     *  病床视图
     **/
    val Database.tJzrBeds get() = this.sequenceOf(TJzrBedDao)
    /**
     *  科室视图
     **/
    val tJzrDept = TJzrDeptDao
    /**
     *  科室视图
     **/
    val Database.tJzrDepts get() = this.sequenceOf(TJzrDeptDao)
    /**
     *  病人信息视图
     **/
    val tJzrInfo = TJzrInfoDao
    /**
     *  病人信息视图
     **/
    val Database.tJzrInfo get() = this.sequenceOf(TJzrInfoDao)
    /**
     *  医嘱信息视图
     **/
    val tJzrOrder = TJzrOrderDao
    /**
     *  医嘱信息视图
     **/

    val Database.tJzrOrders get() = this.sequenceOf(TJzrOrderDao)

    val tJzrOut = TJzrOutDao
    val Database.tJzrOuts get() = this.sequenceOf(TJzrOutDao)

    val vJzrInpatientFeeRecord = VJzrInpatientFeeRecordDao
    val Database.vJzrInpatientFeeRecords get() = this.sequenceOf(VJzrInpatientFeeRecordDao)

    val vJzrInspect = VJzrInspectDao
    val Database.vJzrInspects get() = this.sequenceOf(VJzrInspectDao)

    val vJzrTest = VJzrTestDao
    val Database.vJzrTests get() = this.sequenceOf(VJzrTestDao)




    fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.insert(block: AssignmentsBuilder.(T) -> Unit):Int{
        return this.database.insert(this.sourceTable,block)
    }
    fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.upgrade( block: UpdateStatementBuilder.(T) -> Unit):Int{
        return this.database.update(this.sourceTable,block)
    }
    fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.delete(  predicate: (T) -> ColumnDeclaring<Boolean>):Int{
        return this.database.delete(this.sourceTable,predicate)
    }
}
